package com.fang.common.util;

import java.util.concurrent.ThreadLocalRandom;

public class RandomCodeGenerator {
    private static final String CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    private static final int LENGTH = 8;
    private static final int CHARS_LENGTH = CHARS.length();

    public static String generate8RandomCode() {
        char[] code = new char[LENGTH];
        ThreadLocalRandom random = ThreadLocalRandom.current();
        for (int i = 0; i < LENGTH; i++) {
            code[i] = CHARS.charAt(random.nextInt(CHARS_LENGTH));
        }
        return new String(code);
    }
}